package demo6;

//模拟产生一个双色球的中奖号码
//红球 1-33: 6 不重复的,最终结果从小到大的
//蓝球 1-16: 1 nextInt(16)+1
//思路二:模拟现实,从33个球中随机一个一个的取,取完的球从原球数组中删除

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
public class Demo02 {
    private static final ThreadLocalRandom r=ThreadLocalRandom.current();
    public static void main(String[] args) {
        for(int x=0; x<100;x++) {
            int blue = 0;
            int[] red = new int[6];
            blue  =r.nextInt(16)+1;
            int[]ball=new int[33];
            for(int i=0;i<33;i++) {
                ball[i]=i+1;
            }
            for(int i=0;i<red.length;i++) {
                System.out.println(Arrays.toString(ball));
                int index =r.nextInt((33-i));
                red[i]=ball[index];
                System.arraycopy(ball,index+1,ball,index,32-index);
            }
            Arrays.sort(red);
            System.out.println("篮球:"+blue);
            System.out.println("红球:"+Arrays.toString(red));
        }
    }

}
